package com.thanhloyal.exchanger;

import java.util.ArrayList;

import android.util.Log;

public class RateData {
	ArrayList<Double> bidRates;
	ArrayList<Double> askRates;
	ArrayList<String> pairs; 
	
	private static RateData instance = null;
	
	public static RateData getInstance(){
		if(instance == null){
			instance = new RateData();
			instance.bidRates = new ArrayList<Double>();
			instance.askRates = new ArrayList<Double>();
			instance.pairs = new ArrayList<String>();
		}
		
		instance.loadData();
		return instance;
	}
	
	class Pair{
		public String inCurrencyCode;
		public String outCurrencyCode;
		
		public Pair(String inCurrencyCode, String outCurrencyCode) {
			super();
			this.inCurrencyCode = inCurrencyCode;
			this.outCurrencyCode = outCurrencyCode;
		}
		
	}
	
	private void loadData(){
		instance.askRates.add(79.9476);
		instance.askRates.add(550.063);
		instance.askRates.add(185.775);
		instance.askRates.add(4.14556);
		instance.askRates.add(10.6063);
		
		instance.bidRates.add(79.2064);  
		instance.bidRates.add(529.335);
		instance.bidRates.add(181.331);
		instance.bidRates.add(4.14187);
		instance.bidRates.add(10.5970);
		
		instance.pairs.add ("USD/DZD");//(new Pair("USD", "DZD"));
		instance.pairs.add(("USD/CRC"));
		instance.pairs.add(("USD/KZT"));
		instance.pairs.add(("EUR/PLN"));
		instance.pairs.add(("USD/LSL"));
		
	}
	
	
	public void dumpData() {
		if(instance == null){
			Log.v("Loyal", "RateData instance is null"); // perhaps this never happens.
			return;
		}
		if(instance.bidRates.size() != instance.askRates.size() ||
				instance.askRates.size() != instance.pairs.size()){
			
			Log.v("Loyal", "Sizes not equal");
			return;
		}
		
		for (int i = 0; i < instance.bidRates.size(); i++) {
			StringBuffer buff = new StringBuffer("");
			buff.append(instance.pairs.get(i));
			buff.append(" " + instance.bidRates.get(i));
			buff.append(" " + instance.askRates.get(i));
			Log.v("Loyal", buff.toString());
		}
	}
}
